<template>
	<view>
		<u-navbar :border-bottom="false" title-color="#333" title-bold title="投诉建议" title-size="36"></u-navbar>
		
		<view class="d-id u-padding-24">
			<view class="font_weight u-p-b-16">
				反馈与建议
			</view>
			<view class="textarea-d">
				<u-input maxlength="100" v-model="content" type="textarea" height="280" placeholder="请您写出对平台的反馈及意见！" />
			</view>
			<view class="u-m-t-10">
				<u-upload width="186" height="186" max-count="6" :form-data="formData" :max-size="1 * 1024 * 1024" :deletable="false"
					:action="action" :file-list="fileList" @on-success="onSuccess"></u-upload>
			</view>
		</view>
		<view class="d-id">
			<view class="d-item flex border_bottom_F6F6F6">
				<view class="d-item-t u-m-r-14 font_weight">
					联系人姓名
				</view>
				<u-input  v-model="name" />
			</view>
			<view class="d-item flex">
				<view class="d-item-t u-m-r-14 font_weight">
					联系电话
				</view>
				<u-input  v-model="mobile" />
			</view>
			
		</view>
		<view class="" style="width: 100%;height: 170rpx;"></view>
		
		<u-popup v-model="wcshow" mode="center" border-radius="32">
			<view class="popupmd text_center">
				<view class="font_16_333 font_weight">
					提交成功
				</view>
				<view class="font_12_666 u-m-t-28">
					您的声音是对我们最大的支持谢谢您的反馈！
				</view>
				<view class="p-bd u-m-t-50 flex flex_cen">
					<view class="p-btn2" @click="back">
						完成
					</view>
				</view>
			</view>
		</u-popup>
		
		<view class="btn-bo">
			<button class="btn_login_btn" @click="submit">
				提交意见反馈
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				wcshow:false,
				name:'',
				mobile:'',
				list: [],
				content: '',
				// 演示地址，请勿直接使用
				action: '',
				fileList: [],
				images:[],
				formData: {
					token: uni.getStorageSync("token")
				}
			}
		},
		onLoad() {
			this.action = this.$config.uploadUrl
			console.log(this.action)
		},
		methods: {
			back(){
				uni.navigateBack()
			},
			onSuccess(data, index, lists, name) {
				console.log(data)
				this.images.push(data.data.path)
			},
			submit(){
				if (!this.content) {
					uni.showToast({
						title: "请输入内容",
						icon: "none"
					});
					return
				}
				if (!this.name) {
					uni.showToast({
						title: "请输入姓名",
						icon: "none"
					});
					return
				}
				if (!this.mobile) {
					uni.showToast({
						title: "请输入电话",
						icon: "none"
					});
					return
				}
				this.$api({
					url: '/createGuestBook',
					method: 'post',
					data: {
						token: uni.getStorageSync("token"),
						name:this.name,
						mobile:this.mobile,
						content:this.content,
						images:this.images
					},
				}).then(res => {
					if (res.code == 1) {
						this.wcshow = true
						
					}
				})
			},
		

			
		}
	}
</script>

<style scoped lang="scss">
	.popupmd{
		width: 554rpx;
		// height: 344rpx;
		background: linear-gradient( 180deg, #FFECEA 0%, #FFFFFF 100%);
		padding: 68rpx 24rpx;
		
		
		.p-bd{
			font-size: 28rpx;
			line-height: 64rpx;
			text-align: center;
			
			.p-btn2{
				width: 248rpx;
				height: 64rpx;
				background: linear-gradient( 180deg, #FA2D2D 0%, #F40000 100%);
				border-radius: 46rpx 46rpx 46rpx 46rpx;
				color: #FFFFFF;
			}
		}
		
		
	}
	.btn-bo{
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 8rpx 2rpx rgba(0,0,0,0.14);
		padding-top: 14rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 9;
		
		.btn_login_btn{
			width: 686rpx;
			height: 90rpx;
			background: linear-gradient( 180deg, #FA2D2D 0%, #F40000 100%);
			border-radius: 46rpx 46rpx 46rpx 46rpx;
			// margin-top: 116rpx;
			font-size: 36rpx;
			color: #fff;
			line-height: 90rpx;
			margin-left: 32rpx;
			text-align: center;
			font-weight: bold;
		}
	}
	.d-id {
		width: 702rpx;
		padding:0 24rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 24rpx auto;
		
		.d-item{
			height: 100rpx;
			.d-item-t{
				width: 160rpx;
			}
		}
	}

	.textarea-d {
		width: 640rpx;
		height: 280rpx;
		background: #F8F8F8;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 24rpx;
	}

</style>